//
//  BaseViewController.m
//  YiXiu
//
//  Created by ZHY on 16/6/26.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "BaseViewController.h"
#import "AppDelegate.h"
#import "LeftSortsViewController.h"
#import "LeftSlideViewController.h"
#import "BaseTabBarController.h"


@interface BaseViewController ()



@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self setUpLeftButton];
    
    //添加第三方登录界面
//    [self addLoginView];
    
    //添加基本信息页面
//    [self basicInformationView];
    
    [self settingVCPush];
}



//设置导航栏左边点击侧滑按钮
-(void)setUpLeftButton{
    
    UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    menuBtn.frame = CGRectMake(0, 0, 20, 18);
    [menuBtn setBackgroundImage:[UIImage imageNamed:@"menu"] forState:UIControlStateNormal];
    [menuBtn addTarget:self action:@selector(openOrCloseLeftList) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];
}




- (void) openOrCloseLeftList
{
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    if (tempAppDelegate.LeftSlideVC.closed)
    {
        [tempAppDelegate.LeftSlideVC openLeftView];
    }
    else
    {
        [tempAppDelegate.LeftSlideVC closeLeftView];
    }
}

- (void)settingVCPush{
    AppDelegate * delegat = [UIApplication sharedApplication].delegate;
    LeftSortsViewController * leftvc = (LeftSortsViewController *)((LeftSlideViewController *)delegat.LeftSlideVC).leftVC;
    
    [leftvc setDidBlock:^(UIViewController *vc){
        
        UINavigationController * Navig = delegat.mainNavigationController.viewControllers[delegat.mainNavigationController.selectedIndex];
        NSLog(@"%@",Navig.childViewControllers);
        
        [Navig pushViewController:vc animated:YES];
        
    }];
    
    
    
    
    
}


//
//-(void)addPubliceBlock:(publiceBlock)block{
//    
//    self.block = block;
//
//    self.block(self);
//}


- (loginView *)loginV{
    if (!_loginV) {
        loginView * v = [[loginView alloc] initWithFrame:CGRectZero];
    
        _loginV = v;
    }
    
    [[UIApplication sharedApplication].keyWindow addSubview:_loginV];
     return _loginV;
}

- (void)showLoginView{
    loginView * v = self.loginV;
    CGRect org = v.bounds;
    v.frame = CGRectMake(0, - KScreenHeight, KScreenWidth, KScreenHeight);
    [UIView animateWithDuration:0.5 animations:^{
        v.frame = org;
    }];
    [v orgSubViews];
}



@end
